<include file="public@header" />
</head>
<body>
	<div class="wrap">
		<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('change')}">
			<div>
				<dl>
					<dt></dt>
					<dd>
						<table class="table table-hover table-bordered">
							<tr>
								<td>资料名称</td>
								<td>上传人</td>
								<td>资料类型</td>
								<td>上传时间</td>
								<td>资料下载</td>
							</tr>
							<volist name="files" id="vo">
								<tr>
									<td>{$vo.file_name}</td>
									<td>{$vo.user_nickname}</td>
									<td>
										<switch name="vo.type">
											<case value="3">
												立项资料
											</case>
											<case value="4">
												落定资料
											</case>
											<case value="5">
												变更资料
											</case>
											<case value="6">
												完成资料
											</case>
										</switch>
									</td>
									<td>{$vo.create_time|date="Y-m-d",###}</td>
									<td><a href="{$vo.file|cmf_get_file_download_url}">下载</a></td>
								</tr>
								</switch>
							</volist>
						</table>
					</dd>
				</dl>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>资料上传</label>
				<div class="col-md-6 col-sm-10">
					<ul id="files" class="pic-list list-unstyled form-inline">
					</ul>
					<a href="javascript:uploadMultiFile('附件上传','#files','files-item-tpl');"
					   class="btn btn-sm btn-default">选择文件</a>				</div>
			</div>
			<div class="form-group" id="value_box">
				<label class="col-sm-2 control-label"><span class="form-required">*</span>资料</label>
				<div class="col-sm-10">
					<empty name="lists">
					<div class="input-group">
						<span class="input-group-addon">名称</span>
						<input class="form-control" type="text" name="name[]" value="" />
						<!--<span class="input-group-addon">内容</span>-->
						<!--<input class="form-control" type="text" name="value[]" value="" />-->
						<span class="input-group-addon">日期</span>
						<input class="form-control js-bootstrap-date" type="text" name="date[]" value="" />
						<span class="input-group-addon add btn btn-success" >添加</span>
						<span class="input-group-addon remote btn btn-warning" >移除</span>
					</div>
					<else/>
						<volist name="lists" id="vo">
							<div class="input-group">
								<span class="input-group-addon">名称</span>
								<input class="form-control" type="text" name="name[]" value="{$vo.name}" />
								<!--<span class="input-group-addon">内容</span>-->
								<!--<input class="form-control" type="text" name="value[]" value="" />-->
								<span class="input-group-addon">日期</span>
								<input class="form-control js-bootstrap-date" type="text" name="date[]" value="{$vo.date|date='Y-m-d',###}" />
								<span class="input-group-addon add btn btn-success" >添加</span>
								<span class="input-group-addon remote btn btn-warning" >移除</span>
							</div>
						</volist>
					</empty>
				</div>
			</div>
			<div class="form-group">
				<div class="col-sm-offset-2 col-sm-10">
					<input type="hidden" name="pid" value="{$project.id}"/>
					<button type="submit" class="btn btn-primary js-ajax-submit">提交</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
				</div>
			</div>
		</form>
	</div>
<script src="__STATIC__/js/admin.js"></script>
<script type="text/html" id="files-item-tpl">
	<li id="saved-file{id}">
		<input id="file-{id}" type="hidden" name="file_urls[]" value="{filepath}">
		<div class="input-group">
			<span class="input-group-addon">文件名称</span>
			<input class="form-control" id="file-{id}-name" type="text" name="file_names[]" value="{name}"
				   style="width: 200px;" title="文件名称">
			<span class="input-group-addon btn btn-success" onclick="javascript:uploadOne('图片上传','#file-{id}','file');">替换</span>
			<span class="input-group-addon btn btn-warning" onclick="javascript:(function(){$('#saved-file{id}').remove();})();">移除</span>
		</div>
	</li>
</script>
<script>
$(function(){
    var config = {
        language: 'zh-CN',
        format: 'yyyy-mm-dd',
        minView: 'month',
        todayBtn: 1,
        autoclose: true
    };
    $('#value_box').on('click','.add',function(){
        var box = $(this).parent()
        var new_obj = $(box[0].outerHTML)
        new_obj.find('input').val('')
		new_obj.find('.js-bootstrap-date').datetimepicker(config);

        box.parent().append(new_obj)
	})
    $('#value_box').on('click','.remote',function(){
        if($('#value_box .input-group').size() > 1) {
            $(this).parent().remove();
        }
	})
})
</script>
</body>
</html>